
#include "CDSF_Display.h"


#define kMaxNumberOfScreens 32

static SFView * m_currentRootViews[kMaxNumberOfScreens] = {NULL};

extern const SFView * SFDisplayGetCurrentRootView(SFScreenId screenId){
	return m_currentRootViews[screenId];
}

extern void SFDisplaySetCurrentRootView(SFScreenId screenId, SFView *rootView){
	m_currentRootViews[screenId] = rootView;
}

extern SFCode SFDisplayInit(SFClockRate rate){
	if(SFDisplayMaxScreenId>=kMaxNumberOfScreens)
		return SFCodeSpaceFullError;
	
	return SFCodeOK;
}

extern SFCode SFDisplayDelegate(void){
	SFScreenId screenId;

	for(screenId=0; screenId<=SFDisplayMaxScreenId; screenId++){
		const SFView * view = SFDisplayGetCurrentRootView(screenId);
		
		if(view==NULL)
			continue;

		if((view->viewProcessing)!=NULL)
			view->viewProcessing(view);
		if((view->viewUpdate)!=NULL)
			view->viewUpdate(view, screenId);
	}

	return SFCodeOK;
}
